<?php

namespace app\exam\validate;

use think\Validate;

/**
 * 知识点验证
 */
class Point extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'module_id'     => 'require|number',
        'topic_num'     => 'require|number',
        'category'      => 'number',
        'point_ids' 	=> 'require|/^[\d,]+$/',
        'topic_id'      => 'require|/^[\d,]+$/',
        'topic_level'   => 'require|in:1,2',
        'is_right'      => 'require|in:0,1',

    ];

    protected $field = [
        'module_id'     => '版块',
        'topic_num'     => '出题数',
        'point_ids'     => '知识点',
        'topic_id'      => '试题',
        'topic_level'   => '试题层级',
        'is_right'      => '试题答案结果',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'point_list'        => ['module_id', 'category'],
        'category_list'     => ['module_id'],
        'practice_base'     => ['point_ids', 'module_id', 'topic_num'],
        'point_topic'       => ['topic_id'],
        'topic_answer'      => ['topic_level','topic_id','is_right'],
    ];


}
